package common;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
//import java.sql.SQLException;
import java.sql.Statement;

public class Configuration {
	
	public static String url ="jdbc:mysql://localhost:3306/";
	
	public static String dbName ="dbsurvey";
	
	public static String userName ="root";
	
	public static String password ="root";
	
	public static String driver ="com.mysql.jdbc.Driver";//"org.gjt.mm.mysql.Driver";
	
	private static Connection m_Connection = null;
    
    
	public static Statement GetStatement()
	{
		Statement m_Statement = null;
		try {
			
			Class.forName(Configuration.driver).newInstance();
	        m_Connection = DriverManager.getConnection(Configuration.url+ Configuration.dbName, Configuration.userName, password);//, Configuration.password);
	        m_Statement = m_Connection.createStatement();
	        
		} catch (InstantiationException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

        return m_Statement;
	}
	
	public static void CloseConnection()
	{
		try {
			m_Connection.close();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
